<?php

namespace common\components;

/**
 * @author  shuang
 * @date    2017-2-24 10:06:44
 * @version V1.0
 * @desc    
 */
use yii\web\Controller;
use common\filters\LoginFilter;
use Yii;

class WXController extends Controller {

    public $headerTitle;
    public $headerShow = true;
    public $headerReflash;
    public $headerBack = true;
    public $footerShow = true;
    public $headerRight = [];

    public function behaviors() {
        return [
            'login' => [
                'class' => LoginFilter::className()
            ],
        ];
    }

    public function afterAction($action, $result) {
        if (!Yii::$app->user->isGuest) {
            if (Yii::$app->user->identity->froststatus == 0) {
                $useraccount = \frontendm\models\WB_UserAccountHy::find()->where("userid=:userid", [":userid" => Yii::$app->user->id])->one();
                if ($useraccount) {
                    $event = new \common\components\AccountEvent(["useraccount" => $useraccount]);
                    $this->on("drawalevent", [$event, "drawalTask"]);
                    $this->trigger("drawalevent", $event);
                    $this->off("drawalevent");
                }
            }
            if (Yii::$app->user->identity->froststatus > 0) {
                Yii::$app->controller->redirect(["site/frost"], 301);
            }
        }

        return parent::afterAction($action, $result);
    }

}
